package com.quasar.hpatient.dialog;

import android.app.Activity;
import android.text.TextUtils;
import android.widget.TextView;

import com.quasar.hpatient.R;

import lib.quasar.base.dialog.BaseDialog;

/**
 * description: 删除
 * created by kalu on 2018/4/16 13:15
 */
public class WarningDialog extends BaseDialog {

    private OnDialogChangeListener listener;

    public WarningDialog(Activity activity) {
        super(activity);
    }

    @Override
    protected int initView() {
        return R.layout.layout_dialog_warning;
    }

    @Override
    protected void initData() {

        findViewById(R.id.dialog_delete_single_left).setOnClickListener(v -> {
            if (null != listener) {
                listener.onChange(true, false);
            }
            cancel();
        });
        findViewById(R.id.dialog_delete_single_right).setOnClickListener(v -> {
            if (null != listener) {
                listener.onChange(false, true);
            }
            cancel();
        });
    }

    public void setTitles(CharSequence str) {

        if (TextUtils.isEmpty(str)) return;
        TextView info = findViewById(R.id.dialog_delete_single_title);
        if (null == info) return;
        info.setText(str);
    }


    public void setButton(String left, String right) {

        TextView info1 = findViewById(R.id.dialog_delete_single_left);
        TextView info2 = findViewById(R.id.dialog_delete_single_right);
        info1.setText(left);
        info2.setText(right);
    }

    public void setOnDialogChangeListener(OnDialogChangeListener mListener) {
        this.listener = mListener;
    }

    public interface OnDialogChangeListener {
        void onChange(boolean left, boolean right);
    }
}
